﻿
<div id="dgToolbarAuditLog" class="datagrid-toolbar1">
    <div class="toolbar_right">
    </div>
</div>
<table id="dgAuditLog"></table>

<script>
    (function () {
        var m = 'AuditLog';

        var $toolbar = $('#dgToolbar' + m);
        var $toolbarRight = $toolbar.find('.toolbar_right');
        var $dg = $('#dg' + m);

        var $btnRefresh = $('<a />').insertBefore($toolbarRight);
        $btnRefresh.linkbutton({
            iconCls: 'icon-reload',
            text: abp.localization.zlj('Refresh'),
            plain: true,
            onClick: function () {
                $dg.datagrid('reload');
            }
        });

        var $startDate = $('<input />').appendTo($toolbarRight);
        $startDate.datebox({
            onChange: search
        });
        var $endDate = $('<input />').appendTo($toolbarRight);
        $endDate.datebox({
            onChange: search
        });
        function search() {
            var data = {};
            var startDate = $startDate.datebox('getValue');
            if (startDate)
                data.startDate = startDate;
            var endDate = $endDate.datebox('getValue');
            if (endDate)
                data.endDate = endDate;
            $dg.datagrid('load', data);
        }

        
        $dg.datagrid({
            ctrlSelect: true,
            fit: true,
            checkOnSelect: true,
            selectOnCheck: true,
            singleSelect: false,
            border: false,
            showFooter1: true,
            rownumbers: true,
            pagination: true,
            toolbar: '#dgToolbar' + m,
            url: abp.appPath + 'api/services/app/' + m +'/GetAuditLogs',
            frozenColumns: [[
                { field: 'executionTime', title: '执行时间', width: 210, sortable: true },
                { field: 'userName', title: '用户名', width: 100, sortable: true },
                { field: 'serviceName', title: '服务', width: 180, sortable: true },
                { field: 'methodName', title: '操作', width: 180 }
                //{ field: 'userId', title: '用户Id', width: 60 },
            ]],
            columns: [[
                //{ field: 'impersonatorTenantId', title: '冒名租户Id', width: 100 },
                //{ field: 'impersonatorUserId', title: '冒名用户Id', width: 100 },
                //{ field: 'parameters', title: '参数', width: 300 },
                { field: 'executionDuration', title: '持续时长', width: 80, sortable: true, formatter: function (val, row, index) { return val+'ms'} },
                { field: 'clientIpAddress', title: '客户端IP', width: 120, sortable: true },
                { field: 'parameters', title: '参数', width: 300 },
                //{ field: 'clientName', title: '客户端机器名', width: 100 },
                { field: 'browserInfo', title: '浏览器信息', width: 300 },
                //{ field: 'exception', title: '异常信息', width: 100 },
                //{ field: 'customData', title: '客户时间？', width: 130 }
            ]]
        });
     }());
</script>
